package org.gnuhpc.location;

import java.util.ArrayList;

import com.google.android.maps.GeoPoint;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class LocationUtil {
	private static int SCREEN_WIDTH, SCREEN_HEIGHT;
	private static double ZOOM_FACTOR = 0.8;
	private Activity mActivity;
	
	private static final String LOG_TAG = "ShowLocation";
	
	public LocationUtil(Activity activity) {
		super();
		this.mActivity = activity;
		SCREEN_WIDTH = mActivity.getWindowManager().getDefaultDisplay().getWidth();   
	    SCREEN_HEIGHT = mActivity.getWindowManager().getDefaultDisplay().getHeight();   
	    Log.d(LOG_TAG, SCREEN_WIDTH + " " + SCREEN_HEIGHT);
	}
	
	public static int getSCREEN_WIDTH() {
		return SCREEN_WIDTH;
	}
	
	public static int getSCREEN_HEIGHT() {
		return SCREEN_HEIGHT;
	}

	public static double getZOOM_FACTOR() {
		// TODO Auto-generated method stub
		return ZOOM_FACTOR;
	}
	
	public GeoPoint clickPointBundleHandler(Bundle bundle){
		GeoPoint geoPoint;
		int size = bundle.size();
		Log.d(LOG_TAG, "bundle size is " + size);
		switch (size) {
		case 2:
			geoPoint = new GeoPoint(bundle.getInt("lat"), bundle.getInt("lon"));
			break;
		default:
			geoPoint = null;
			break;
		}			
		return geoPoint;		
	}
	
	public GeoPoint searchBundleHandler(Bundle bundle){
		GeoPoint geoPoint;
		int size = bundle.size();
		Log.d(LOG_TAG, "bundle size is " + size);
		switch (size) {
		case 2:
			geoPoint = new GeoPoint((int)(bundle.getDouble("lat")*1e6), (int)(bundle.getDouble("lon")*1e6));
			break;
		default:
			geoPoint = null;
			break;
		}			
		return geoPoint;		
	}
}
